package cn.yuanqiao.web.controller.activiti;

import cn.yuanqiao.activiti.domain.ActArchiveData;
import cn.yuanqiao.activiti.service.IActArchiveDataService;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.core.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 流程档案数据绑定Controller
 * 
 * @author lyk
 * @date 2023-07-11
 */
@RestController
@RequestMapping("/activiti/archiveData")
public class ActArchiveDataController extends BaseController
{
    @Autowired
    private IActArchiveDataService actArchiveDataService;

    /**
     * 查询流程档案数据绑定列表
     */
    @PreAuthorize("@ss.hasPermi('activiti:archiveData:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActArchiveData actArchiveData)
    {
        startPage();
        List<ActArchiveData> list = actArchiveDataService.selectActArchiveDataList(actArchiveData);
        return getDataTable(list);
    }

    /**
     * 导出流程档案数据绑定列表
     */
    @PreAuthorize("@ss.hasPermi('activiti:archiveData:export')")
    @Log(title = "流程档案数据绑定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActArchiveData actArchiveData)
    {
        List<ActArchiveData> list = actArchiveDataService.selectActArchiveDataList(actArchiveData);
        ExcelUtil<ActArchiveData> util = new ExcelUtil<ActArchiveData>(ActArchiveData.class);
        util.exportExcel(response, list, "流程档案数据绑定数据");
    }

    /**
     * 获取流程档案数据绑定详细信息
     */
    @PreAuthorize("@ss.hasPermi('activiti:archiveData:query')")
    @GetMapping(value = "/{deployId}")
    public AjaxResult getInfo(@PathVariable("deployId") String deployId)
    {
        return success(actArchiveDataService.selectActArchiveDataByDeployId(deployId));
    }

    /**
     * 新增流程档案数据绑定
     */
    @PreAuthorize("@ss.hasPermi('activiti:archiveData:add')")
    @Log(title = "流程档案数据绑定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActArchiveData actArchiveData)
    {
        return toAjax(actArchiveDataService.insertActArchiveData(actArchiveData));
    }

    /**
     * 修改流程档案数据绑定
     */
    @PreAuthorize("@ss.hasPermi('activiti:archiveData:edit')")
    @Log(title = "流程档案数据绑定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActArchiveData actArchiveData)
    {
        return toAjax(actArchiveDataService.updateActArchiveData(actArchiveData));
    }

    /**
     * 删除流程档案数据绑定
     */
    @PreAuthorize("@ss.hasPermi('activiti:archiveData:remove')")
    @Log(title = "流程档案数据绑定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deployIds}")
    public AjaxResult remove(@PathVariable String[] deployIds)
    {
        return toAjax(actArchiveDataService.deleteActArchiveDataByDeployIds(deployIds));
    }
}
